package com.zte.claa.inficombo.csa.app.service.sapi.ffhost;

import java.util.List;
import java.util.Map;

public class FFTransDevCommand {
	public static final int CMD_CODE_REQ = 4;
	public static final int CMD_CODE_CTRL = 1; 
	
	// 各类命令参数在parasmap中的key名称.
	// List<FFCmdTarget>
	public static final String PARA_MAPKEY_TARGETS = "cmdtargetlist"; 
	// int, 读取数据的最大记录数.
	public static final String PARA_MAPKEY_ROWNUM = "queryrownum";
	// FFDateTime，开始时间参数
	public static final String PARA_MAPKEY_BEGINDATETIME = "begindatetime";
	// FFDateTime，截止时间参数
	public static final String PARA_MAPKEY_ENDDATETIME = "enddatetime";
	// FFDateTime，中心系统时间参数
	public static final String PARA_MAPKEY_SVRDATETIME = "svrdatetime";
	// int, 查岗应答超时时间，单位：分钟.
	public static final String PARA_MAPKEY_ACKEXPTIME = "ackexpireminutes";
	
	// 4=请求命令；1=控制命令（时间同步）；
	private int cmdcode = 4;
	private int typeflag = 0;
	private Map<String, Object> paras = null;
	
	public FFTransDevCommand(){
		
	}

	public int getCmdcode() {
		return cmdcode;
	}

	public void setCmdcode(int cmdcode) {
		this.cmdcode = cmdcode;
	}

	public Map<String, Object> getParas() {
		return paras;
	}

	public void setParas(Map<String, Object> paras) {
		this.paras = paras;
	}

	public int getTypeflag() {
		return typeflag;
	}

	public void setTypeflag(int typeflag) {
		this.typeflag = typeflag;
	}
	
	@SuppressWarnings("unchecked")
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("cmdcode=").append(cmdcode).append(", ");
		sb.append("typeflag=").append(typeflag).append(", ");
		if(this.paras != null){
			Object obj = this.paras.get(PARA_MAPKEY_TARGETS);
			if(obj != null){
				int cc = 0;
				List<FFCmdTarget> tartgetList = (List<FFCmdTarget>)obj;
				for(FFCmdTarget target : tartgetList){
					sb.append("target[").append(cc++).append("]=").append(target.toString()).append("; ");
				}
			}
			obj = this.paras.get(PARA_MAPKEY_ROWNUM);
			if(obj != null){
				sb.append("queryrownum=").append(obj).append("; ");
			}
			obj = this.paras.get(PARA_MAPKEY_BEGINDATETIME);
			if(obj != null){
				sb.append("begindatetime=").append(obj).append("; ");
			}
			obj = this.paras.get(PARA_MAPKEY_ENDDATETIME);
			if(obj != null){
				sb.append("enddatetime=").append(obj).append("; ");
			}
			obj = this.paras.get(PARA_MAPKEY_SVRDATETIME);
			if(obj != null){
				sb.append("svrdatetime=").append(obj).append("; ");
			}
			obj = this.paras.get(PARA_MAPKEY_ACKEXPTIME);
			if(obj != null){
				sb.append("ackexpireminutes=").append(obj).append("; ");
			}
		}		
		sb.append("cmdcode=").append(cmdcode).append(", ");
		return sb.toString();
	}
}
